fix(browser): wait for iframe tester readiness before preparing#10497
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
I am confused why we need multiple id trackers. There can only be one iframe on the page at a time, the There should never be any "stale" or "reloaded" iframes |
| @@ -0,0 +1,150 @@ | |||
| // @vitest-environment happy-dom | |||
There was a problem hiding this comment.
I would prefer tests that actually fail without you change (even if not always). Having unit tests for the registry doesn't give me any confidence that API works in a real orchestrator. Especially because there is supposed to only be a single iframe anyway. The idea of having a registry with this premise sounds a bit ridiculous, not gonna lie
There was a problem hiding this comment.
The idea of having a registry with this premise sounds a bit ridiculous, not gonna lie
Yea it was. I was trusting Codex's answers about how it was possible that there would be stale events coming from <iframe>s that needed to be disambiguated.
I've removed this unit test and with Codex was able to make a test/browser/specs/readiness.test.ts integration test file which fails on the current main branch but passes w/ this code change.
|
I've also noticed that after your previous PR we are getting |
Oh dang! Probably best to revert that PR then. 😞 |
d9f85f2 to
34a49e6
Compare
| startTime, | ||
| otelCarrier: this.traces.getContextCarrier(otelContext), | ||
| }).then(resolve, error => reject(this.dispatchIframeError(error))) | ||
| this.waitForReady(iframeId) |
There was a problem hiding this comment.
This is where the actual bug-fix is. Instead of just assuming we can this.sendEventToIframe({ event: 'prepare', ... }) we now wait until the <iframe> has told us it is ready.
34a49e6 to
62244f4
Compare
62244f4 to
5ba3c64
Compare
|
LGTM, please confirm that the fix works for your use case 🙏 |
@vitest/browser
@vitest/browser-playwright
@vitest/browser-preview
@vitest/browser-webdriverio
@vitest/coverage-istanbul
@vitest/coverage-v8
@vitest/expect
@vitest/mocker
@vitest/pretty-format
@vitest/snapshot
@vitest/spy
@vitest/ui
@vitest/utils
vitest
@vitest/web-worker
commit: |
Yes I tested this PR's build version of |
…) [backport to v4] (#10556) Co-authored-by: Séamus O'Connor <seamus.oconnor@seeq.com>
Description
During the investigation for
vitest-randomly-hanging-in-CI I (with the help of Codex) initially diagnosed a race condition that was ultimately fixed but I still was getting CI failures / hangs (even after that first fix) — exposing another race condition.It's a browser-runner readiness race where the orchestrator could send the initial
prepareevent before the tester<iframe>was actually ready to receive channel messages.Resolves (do you need an issue for a bug fix?)
This PR adds an explicit tester-ready handshake between the browser tester and orchestrator.
Changes
<iframe>channel event:readyreadyonly after its channel listener is registered<iframe>to reportreadybefore sendingpreparePlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.AI assisted: Codex